<template>
  <div class="app-container">
    <el-tabs v-model="activeName" @tab-click="handleClick" :stretch="true">
      <el-tab-pane label="申购" name="apply">
        <apply ref="apply"></apply>
      </el-tab-pane>
      <el-tab-pane label="采购" name="buy">
        <buy ref="buy"></buy>
      </el-tab-pane>
      <el-tab-pane label="验收入库" name="inbound">
        <inbound ref="inbound"></inbound>
      </el-tab-pane>
      <el-tab-pane label="库存" name="stock">
        <stock ref="stock"></stock>
      </el-tab-pane>
      <el-tab-pane label="领用" name="receive">
        <receive ref="receive"></receive>
      </el-tab-pane>
      <el-tab-pane label="库存流水" name="stockflow">
        <stocklog ref="stocklog"></stocklog>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import Apply from '../apply/index'
import Buy from '../buy/index'
import Inbound from '../inbound/index'
import Stock from '../stock/index'
import Receive from '../receive/index'
import Stocklog from '../stocklog/index'

export default {
  name: 'Flow',
  components: {
    Apply,
    Buy,
    Inbound,
    Stock,
    Receive,
    Stocklog,
  },
  data() {
    return {
      activeName: this.$route.query.activeName ? this.$route.query.activeName : 'inbound',
    }
  },
  methods: {
    handleClick() {
      const self = this
      switch (self.activeName) {
        case 'buy':
          self.$refs.buy.getReagentBuy()
          break
        case 'apply':
          self.$refs.apply.getReagentApply()
          break
        case 'inbound':
          self.$refs.inbound.getReagentBuy()
          break
        case 'stock':
          self.$refs.stock.getReagentStock()
          break
        case 'receive':
          self.$refs.receive.getReagentReceive()
          break
        case 'stocklog':
          self.$refs.stocklog.getReagentStockLog()
          self.$refs.stocklog.getReagentStockLog2()
          break
        default:
          break
      }
    },
  },
}
</script>

<style></style>
